home *** CD-ROM | disk | FTP | other *** search
-
-
-
- rrrrmmmmaaaalllllllloooocccc((((DDDD3333)))) rrrrmmmmaaaalllllllloooocccc((((DDDD3333))))
-
-
-
- NNNNAAAAMMMMEEEE
- _rrrr_mmmm_aaaa_llll_llll_oooo_cccc - allocate space from a private space management map
-
- SSSSYYYYNNNNOOOOPPPPSSSSIIIISSSS
- _####_iiii_nnnn_cccc_llll_uuuu_dddd_eeee _<<<<_ssss_yyyy_ssss_////_tttt_yyyy_pppp_eeee_ssss_...._hhhh_>>>>
- _####_iiii_nnnn_cccc_llll_uuuu_dddd_eeee _<<<<_ssss_yyyy_ssss_////_mmmm_aaaa_pppp_...._hhhh_>>>>
- _####_iiii_nnnn_cccc_llll_uuuu_dddd_eeee _<<<<_ssss_yyyy_ssss_////_dddd_dddd_iiii_...._hhhh_>>>>
- _uuuu_llll_oooo_nnnn_gggg______tttt _rrrr_mmmm_aaaa_llll_llll_oooo_cccc_((((_ssss_tttt_rrrr_uuuu_cccc_tttt _mmmm_aaaa_pppp _****_m_p_,,,, _ssss_iiii_zzzz_eeee______tttt _s_i_z_e_))))_;;;;
-
- AAAArrrrgggguuuummmmeeeennnnttttssss
- _m_p Pointer to the map from which space is to be allocated.
-
- _s_i_z_e Number of units of space to allocate.
-
- DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN
- _rrrr_mmmm_aaaa_llll_llll_oooo_cccc allocates space from the private space management map pointed to
- by _m_p.
-
- RRRReeeettttuuuurrrrnnnn VVVVaaaalllluuuueeeessss
- Upon successful completion, _rrrr_mmmm_aaaa_llll_llll_oooo_cccc returns the base of the allocated
- space. If _s_i_z_e units cannot be allocated, 0 is returned.
-
- UUUUSSSSAAAAGGGGEEEE
- Drivers can use _rrrr_mmmm_aaaa_llll_llll_oooo_cccc to allocate space from a previously allocated and
- initialized private space management map.
-
- The map must have been allocated by a call to _rrrr_mmmm_aaaa_llll_llll_oooo_cccc_mmmm_aaaa_pppp(D3) and the
- space managed by the map must have been added using _rrrr_mmmm_ffff_rrrr_eeee_eeee(D3) prior to
- the first call to _rrrr_mmmm_aaaa_llll_llll_oooo_cccc for the map.
-
- _s_i_z_e specifies the amount of space to allocate and is in arbitrary units.
- The driver using the map places whatever semantics on the units are
- appropriate for the type of space being managed. For example, units may
- be byte addresses, pages of memory, or blocks on a device.
-
- The system allocates space from the memory map on a first-fit basis and
- coalesces adjacent space fragments when space is returned to the map by
- _rrrr_mmmm_ffff_rrrr_eeee_eeee.
-
- LLLLeeeevvvveeeellll
- Initialization, Base or Interrupt.
-
- SSSSyyyynnnncccchhhhrrrroooonnnniiiizzzzaaaattttiiiioooonnnn CCCCoooonnnnssssttttrrrraaaaiiiinnnnttttssss
- Does not sleep.
-
- Driver-defined basic locks, read/write locks, and sleep locks may be held
- across calls to this function.
-
- EEEExxxxaaaammmmpppplllleeeessss
- The following example is a simple memory map, but it illustrates the
- principles of map management. A driver declares a map table (line 4) and
- initializes the map table by calling the _rrrr_mmmm_ffff_rrrr_eeee_eeee function. There are 35
-
-
- PPPPaaaaggggeeee 1111
-
-
-
-
-
-
- rrrrmmmmaaaalllllllloooocccc((((DDDD3333)))) rrrrmmmmaaaalllllllloooocccc((((DDDD3333))))
-
-
-
- entries in the map table, 32 of which can be used to represent space
- allocated. In the driver's _ssss_tttt_aaaa_rrrr_tttt(D2) routine, we allocate 16 Kbytes of
- memory using _rrrr_mmmm_aaaa_llll_llll_oooo_cccc_mmmm_aaaa_pppp(D3) (line 8). This is the space to be managed.
- Then call _rrrr_mmmm_ffff_rrrr_eeee_eeee to populate the map with the space it is to manage (line
- 10).
-
- In the driver's _rrrr_eeee_aaaa_dddd(D2) and _wwww_rrrr_iiii_tttt_eeee(D2) routines, we use _rrrr_mmmm_aaaa_llll_llll_oooo_cccc to
- allocate buffers for data transfer. This example illustrates the _wwww_rrrr_iiii_tttt_eeee
- routine. Assuming the device can only transfer _XXXX_XXXX______MMMM_AAAA_XXXX_BBBB_UUUU_FFFF_SSSS_ZZZZ bytes at a
- time, we calculate the amount of data to copy (line 21) and use _rrrr_mmmm_aaaa_llll_llll_oooo_cccc
- to allocate some space from the map. The call to _rrrr_mmmm_aaaa_llll_llll_oooo_cccc is protected
- against interrupts (line 22) from the device that may result in freeing
- map space. This way, if space is freed, we won't miss the corresponding
- _wwww_aaaa_kkkk_eeee_uuuu_pppp(D3).
-
- _1111 _####_dddd_eeee_ffff_iiii_nnnn_eeee _XXXX_XXXX______MMMM_AAAA_PPPP_SSSS_IIII_ZZZZ_EEEE _3333_5555
- _2222 _####_dddd_eeee_ffff_iiii_nnnn_eeee _XXXX_XXXX______MMMM_EEEE_MMMM_SSSS_IIII_ZZZZ_EEEE _((((_1111_6666_****_1111_0000_2222_4444_))))
- _3333 _####_dddd_eeee_ffff_iiii_nnnn_eeee _XXXX_XXXX______MMMM_AAAA_XXXX_BBBB_UUUU_FFFF_SSSS_ZZZZ _1111_0000_2222_4444
- _4444 _ssss_tttt_rrrr_uuuu_cccc_tttt _mmmm_aaaa_pppp _****_xxxx_xxxx______mmmm_aaaa_pppp_;;;;
- _...._...._....
- _5555 _xxxx_xxxx______ssss_tttt_aaaa_rrrr_tttt_((((_))))
- _6666 _{{{{
- _7777 _cccc_aaaa_dddd_dddd_rrrr______tttt _bbbb_pppp_;;;;
- _8888 _iiii_ffff _((((_((((_mmmm_pppp_====_rrrr_mmmm_aaaa_llll_llll_oooo_cccc_mmmm_aaaa_pppp_((((_xxxx_xxxx______MMMM_AAAA_PPPP_SSSS_IIII_ZZZZ_EEEE_)))) _====_==== _0000
- _9999 _cccc_mmmm_nnnn______eeee_rrrr_rrrr _((((_CCCC_EEEE______PPPP_AAAA_NNNN_IIII_CCCC_,,,, _""""_xxxx_xxxx______ssss_tttt_aaaa_rrrr_tttt_:::: _cccc_oooo_uuuu_llll_dddd _nnnn_oooo_tttt _aaaa_llll_llll_oooo_cccc_aaaa_tttt_eeee _mmmm_aaaa_pppp_""""_))))_;;;;
- _1111_0000 _rrrr_mmmm_ffff_rrrr_eeee_eeee_((((_xxxx_xxxx______mmmm_aaaa_pppp_,,,, _XXXX_XXXX______MMMM_EEEE_MMMM_SSSS_IIII_ZZZZ_EEEE_,,,, _bbbb_pppp_))))_;;;;
- _1111_1111 _}}}}
- _...._...._....
- _1111_2222 _xxxx_xxxx______wwww_rrrr_iiii_tttt_eeee_((((_dddd_eeee_vvvv_,,,, _uuuu_iiii_oooo_pppp_,,,, _cccc_rrrr_pppp_))))
- _1111_3333 _dddd_eeee_vvvv______tttt _dddd_eeee_vvvv_;;;;
- _1111_4444 _uuuu_iiii_oooo______tttt _****_uuuu_iiii_oooo_pppp_;;;;
- _1111_5555 _cccc_rrrr_eeee_dddd______tttt _****_cccc_rrrr_pppp_;;;;
- _1111_6666 _{{{{
- _1111_7777 _cccc_aaaa_dddd_dddd_rrrr______tttt _aaaa_dddd_dddd_rrrr_;;;;
- _1111_8888 _ssss_iiii_zzzz_eeee______tttt _ssss_iiii_zzzz_eeee_;;;;
- _1111_9999 _iiii_nnnn_tttt _ssss_;;;;
- _...._...._....
- _2222_0000 _wwww_hhhh_iiii_llll_eeee _((((_uuuu_iiii_oooo_pppp_----_>>>>_uuuu_iiii_oooo______rrrr_eeee_ssss_iiii_dddd _>>>> _0000_)))) _{{{{
- _2222_1111 _ssss_iiii_zzzz_eeee _==== _mmmm_iiii_nnnn_((((_uuuu_iiii_oooo_pppp_----_>>>>_uuuu_iiii_oooo______rrrr_eeee_ssss_iiii_dddd_,,,, _XXXX_XXXX______MMMM_AAAA_XXXX_BBBB_UUUU_FFFF_SSSS_ZZZZ_))))_;;;;
- _2222_2222 _ssss _==== _ssss_pppp_llll_4444_((((_))))_;;;;
- _2222_3333 _wwww_hhhh_iiii_llll_eeee _((((_((((_aaaa_dddd_dddd_rrrr _==== _((((_cccc_aaaa_dddd_dddd_rrrr______tttt_))))_rrrr_mmmm_aaaa_llll_llll_oooo_cccc_((((_xxxx_xxxx______mmmm_aaaa_pppp_,,,, _ssss_iiii_zzzz_eeee_))))_)))) _====_==== _NNNN_UUUU_LLLL_LLLL_)))) _{{{{
- _2222_4444 _ssss_llll_eeee_eeee_pppp_((((_((((_cccc_aaaa_dddd_dddd_rrrr______tttt_))))_xxxx_xxxx______mmmm_aaaa_pppp_,,,, _PPPP_ZZZZ_EEEE_RRRR_OOOO_))))_;;;;
- _2222_5555 _}}}}
- _2222_6666
- _2222_7777 _ssss_pppp_llll_xxxx_((((_ssss_))))_;;;;
- _...._...._....
- _2222_8888 _}}}}
- _...._...._....
-
-
-
-
-
-
- PPPPaaaaggggeeee 2222
-
-
-
-
-
-
- rrrrmmmmaaaalllllllloooocccc((((DDDD3333)))) rrrrmmmmaaaalllllllloooocccc((((DDDD3333))))
-
-
-
- RRRREEEEFFFFEEEERRRREEEENNNNCCCCEEEESSSS
- _rrrr_mmmm_aaaa_llll_llll_oooo_cccc______wwww_aaaa_iiii_tttt(D3), _rrrr_mmmm_aaaa_llll_llll_oooo_cccc_mmmm_aaaa_pppp(D3), _rrrr_mmmm_ffff_rrrr_eeee_eeee(D3), _rrrr_mmmm_ffff_rrrr_eeee_eeee_mmmm_aaaa_pppp(D3),
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- PPPPaaaaggggeeee 3333
-
-
-
-